package com.xk._01基础篇._05队列Queue;

import com.xk._01基础篇._05队列Queue.circle.CircleDeque;
import com.xk._01基础篇._05队列Queue.circle.CircleQueue;

/**
 * @description:
 * @author: xu
 * @date: 2022/9/18 22:28
 */
public class Main {
    public static void main(String[] args) {
        CircleDeque<Integer> circleDeque = new CircleDeque<>();
        // 5 4 3 2 1 100 101 102 103 104
        // 5 4 3 2 1 100 101 102 103 104 null null null null null
        // 5 4 3 2 1 100 101 102 103 104 105 106 8 7 6
        // 5 4 3 2 1 100 101 102 103 104 105 106 8 7 6 null null null null null null null
        // 8 7 6 5 4 3 2 1 100 101 102 103 104 105 106 107 108 109 null null 10 9
        for (int i = 0; i < 10; i++) {
            circleDeque.enQueueFront(i + 1);
            circleDeque.enQueueRear(i + 100);
        }
        System.out.println(circleDeque);

        // 8 7 6 5 4 3 2 1 100 101 102 103 104 105 106 107 108 109 null null 10 9
        // null 7 6 5 4 3 2 1 100 101 102 103 104 105 106 null null null null null null null
        for (int i = 0; i < 3; i++) {
            circleDeque.deQueueFront();
            circleDeque.deQueueRear();
        }
        System.out.println(circleDeque);

        // null 7 6 5 4 3 2 1 100 101 102 103 104 105 106 null null null null null null null
        // 11 7 6 5 4 3 2 1 100 101 102 103 104 105 106 null null null null null null 12
        circleDeque.enQueueFront(11);
        circleDeque.enQueueFront(12);
        System.out.println(circleDeque);

        while (!circleDeque.isEmpty()){
            System.out.println(circleDeque.deQueueFront());
        }
    }

    private static void testCircleQueue(){
        CircleQueue<Integer> circleQueue = new CircleQueue<>();
        for (int i = 0; i < 10; i++) {
            circleQueue.enQueue(i);
            // 0 1 2 3 4 5 6 7 8 9
        }
        for (int i = 0; i < 5; i++) {
            circleQueue.deQueue();
            // null null null null null 5 6 7 8 9
        }
        System.out.println(circleQueue);
        for (int i = 15; i < 25; i++) {
            circleQueue.enQueue(i);
        }
        System.out.println(circleQueue);
        while (!circleQueue.isEmpty()){
            System.out.println(circleQueue.deQueue());
        }
    }

    private static void testDeque(){
        Deque<Integer> deque = new Deque<>();

        deque.enQueueFront(11);
        deque.enQueueFront(22);
        deque.enQueueRear(33);
        deque.enQueueRear(44);
        // 22 11 33 44
        while (!deque.isEmpty()){
            System.out.println(deque.deQueueRear());
        }
    }

    private static void testQueue(){
        Queue<Integer> queue = new Queue<>();
        queue.enQueue(11);
        queue.enQueue(22);
        queue.enQueue(33);
        queue.enQueue(44);
        queue.enQueue(55);

        while (!queue.isEmpty()){
            System.out.println(queue.deQueue());
        }
    }
}
